#include "InitSave.h"

#include "Parameters.h"
#include "Layer.h"

#include <QString>
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstdlib>

using namespace std;

InitSave::InitSave()
{

}

InitSave::~InitSave()
{

}

int InitSave::save(Output output,int choice)
{

  //copy Parameters file
  QString command="cp ../Parameters.cc ";
  command+=output.getParamsFile();
  system(command.c_str());
  //copy Polarization file
  command="cp ../SpinTorque.cc ";
  command+=output.getPolarizationFile();
  system(command.c_str());

  //column titles and units for the output file
  ofstream myfile;
  myfile.open(output.getFileName().c_str(), ios::out | ios::app);

  if(choice==1) //trajectory
    { 
      myfile<<"Time\t";
      myfile<<"Current\t";
      myfile<<"mx\t";
      myfile<<"my\t";
      myfile<<"mz"<<endl;
      myfile<<"ns\t";
      myfile<<"mA\t";
      myfile<<endl;
    }
  
  if(choice==3) //icrit vs length
    {
      myfile<<"1/t\t";
      myfile<<"t\t";
      myfile<<"Ic"<<endl;
      myfile<<"Hz\t";
      myfile<<"s\t";
      myfile<<"A";
      myfile<<endl;
    }
	 
  if(choice==8)
    {
      myfile<<"hx\t";
      myfile<<"hy\t";
      myfile<<"hz\t";
      myfile<<"mx\t";
      myfile<<"my\t";
      myfile<<"mz";
      myfile<<endl;
    }
  myfile.close(); 
  return 0;
}
